home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / fgl105c.zip / 06-10.C < prev    next >
Text File  |  1991-05-05  |  703b  |  34 lines

  1. #define RECTANGLES 200
  2. #define SWAP(a,b,temp) { temp = a; a = b; b = temp; }
  3.  
  4. main()
  5. {
  6.    int i;
  7.    int minx, maxx, miny, maxy;
  8.    int old_mode;
  9.    int temp;
  10.    int xres, yres;
  11.  
  12.    old_mode = fg_getmode();
  13.    fg_setmode(fg_automode());
  14.  
  15.    xres = fg_getmaxx() + 1;
  16.    yres = fg_getmaxy() + 1;
  17.  
  18.    for (i = 0; i < RECTANGLES; i++) {
  19.       minx = rand() % xres;
  20.       maxx = rand() % xres;
  21.       miny = rand() % yres;
  22.       maxy = rand() % yres;
  23.       if (minx > maxx)
  24.          SWAP(minx,maxx,temp);
  25.       if (miny > maxy)
  26.          SWAP(miny,maxy,temp);
  27.       fg_setcolor(rand()%16);
  28.       fg_rect(minx,maxx,miny,maxy);
  29.       }
  30.  
  31.    fg_setmode(old_mode);
  32.    fg_reset();
  33. }
  34.